package com.choosefine.it.company.controller;


import com.choosefine.it.common.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.choosefine.it.base.BaseController;
import com.choosefine.it.base.dto.PageDTO;
import com.choosefine.it.common.def.ResultCode;
import com.choosefine.it.company.model.vo.CompanyEvaluationInfoVO;
import com.choosefine.it.company.service.CompanyEvaluationInfoService;
import com.github.pagehelper.Page;

/**
 * 建筑公司-评价管理
 * @author chenjian
 * @date 2016-12-3 下午2:18:28
 */
@RestController
@RequestMapping("/companyEvaluationInfo")
@Api(value="建筑公司评价管理",description="陈健")
public class CompanyEvaluationInfoController extends BaseController{
	@Autowired
	private CompanyEvaluationInfoService companyEvaluationInfoService;
	Logger logger=LoggerFactory.getLogger(CompanyEvaluationInfoController.class);
	@ApiOperation(value = "建筑公司-评价管理-根据用户的usercode查看评价", notes = "",response = CompanyEvaluationInfoVO.class)
	@ApiImplicitParams({@ApiImplicitParam(name = "userCode", value = "用户编号", required = true, dataType = "String",paramType = "path"),
			@ApiImplicitParam(name = "pageNum", value = "起始行", required = true, dataType = "Integer", paramType = "query"),
			@ApiImplicitParam(name = "pageSize", value = "一页显示的行数", required = true, dataType = "Integer", paramType = "query")})
	@RequestMapping(value="/getCompanyEvaluationInfoList/{userCode}",method=RequestMethod.GET,produces = "application/json")
	public String getCompanyEvaluationInfoList(@PathVariable String userCode,Integer pageNum,Integer pageSize){
		String result=null;
		PageDTO page= new PageDTO();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		if(StringUtils.isNotBlank(userCode)){
			Page<CompanyEvaluationInfoVO> list = companyEvaluationInfoService.findCompanyEvaluationInfoList(userCode, page);
			if(list.size()>0){
				result= responseSuccess(list);
			}else{
				result= responseFail(ResultCode.FAILED,ResultCode.MSG_DATA_ISEMPTY);
			}
		}else{
			result= responseFail(ResultCode.FAILED,ResultCode.MSG_PARAMS_NULL);
		}
		return result;
	}
	
}
